home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 4.3 KB | 142 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWGrObj.cpp
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWGROBJ_H
- #include "FWGrObj.h"
- #endif
-
- #ifndef FWDFAULT_H
- #include "FWDfault.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- //==============================================================================
- // •• RunTime Info
- //==============================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphx
- #endif
-
- //==============================================================================
- // •• class FW_CGraphicObjectRep
- //==============================================================================
-
- //------------------------------------------------------------------------------
- // • FW_CGraphicObjectRep::FW_CGraphicObjectRep
- //------------------------------------------------------------------------------
-
- FW_CGraphicObjectRep::FW_CGraphicObjectRep() :
- fSeed(++gGraphicGlobales.gSeed),
- fRefCount(0)
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CGraphicObjectRep::~FW_CGraphicObjectRep
- //------------------------------------------------------------------------------
-
- FW_CGraphicObjectRep::~FW_CGraphicObjectRep()
- {
- }
-
- //------------------------------------------------------------------------------
- // • FW_CGraphicObjectRep::Changed
- //------------------------------------------------------------------------------
-
- void FW_CGraphicObjectRep::Changed()
- {
- fSeed = ++gGraphicGlobales.gSeed;
- }
-
- //==============================================================================
- // •• class FW_CGraphicObjectPtr
- //==============================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicObjectPtr::~FW_CGraphicObjectPtr
- //----------------------------------------------------------------------------------------
-
- FW_CGraphicObjectPtr::~FW_CGraphicObjectPtr()
- {
- DownCount();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicObjectPtr::FW_CGraphicObjectPtr
- //----------------------------------------------------------------------------------------
-
- FW_CGraphicObjectPtr::FW_CGraphicObjectPtr() :
- fRep(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicObjectPtr::FW_CGraphicObjectPtr
- //----------------------------------------------------------------------------------------
-
- FW_CGraphicObjectPtr::FW_CGraphicObjectPtr(const FW_CGraphicObjectPtr& other) :
- fRep(other.fRep)
- {
- UpCount();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicObjectPtr::FW_CGraphicObjectPtr
- //----------------------------------------------------------------------------------------
-
- FW_CGraphicObjectPtr::FW_CGraphicObjectPtr(FW_CGraphicObjectRep* rep) :
- fRep(rep)
- {
- UpCount();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicObjectPtr::UpCount
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicObjectPtr::UpCount()
- {
- if (fRep)
- fRep->IncrementRefCount();
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicObjectPtr::DownCount
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicObjectPtr::DownCount()
- {
- if (fRep && !fRep->Release())
- delete fRep;
- // It is not necessary to set fRep to NULL. To see why, see how DownCount is used above.
- // In all cases, fRep is either immediately reset, or the instance is being destroyed.
- // Note too that DownCount is private.
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CGraphicObjectPtr::SetRep
- //----------------------------------------------------------------------------------------
-
- void FW_CGraphicObjectPtr::SetRep(FW_CGraphicObjectRep* rep)
- {
- if (fRep != rep)
- {
- DownCount();
- fRep = rep;
- UpCount();
- }
- }